Skip to content

[Propagators] Improve JaegerPropagator performance#7171

Merged
martincostello merged 3 commits intoopen-telemetry:mainfrom
martincostello:JaegerPropagator-perf
Apr 27, 2026
Merged

[Propagators] Improve JaegerPropagator performance#7171
martincostello merged 3 commits intoopen-telemetry:mainfrom
martincostello:JaegerPropagator-perf

Conversation

@martincostello
Copy link
Copy Markdown
Member

Changes

Improve the performance of JaegerPropagator for .NET 8+ by using SearchValues<T>.

Benchmark Results

Copilot Summary

JaegerPropagator-perf improves all common Extract benchmarks, while Inject is mixed. Allocations are unchanged across every shared suite.

Suite Method main JaegerPropagator-perf Duration delta Duration ratio Allocation delta Allocation ratio
Sampled=False, UseEncodedDelimiter=False Extract 212.57 ns 98.98 ns -53.4% 0.47x 312 B -> 312 B (0.0%) 1.00x
Sampled=False, UseEncodedDelimiter=False Inject 54.12 ns 28.58 ns -47.2% 0.53x 128 B -> 128 B (0.0%) 1.00x
Sampled=False, UseEncodedDelimiter=True Extract 200.61 ns 92.99 ns -53.6% 0.46x 312 B -> 312 B (0.0%) 1.00x
Sampled=False, UseEncodedDelimiter=True Inject 27.55 ns 28.85 ns +4.7% 1.05x 128 B -> 128 B (0.0%) 1.00x
Sampled=True, UseEncodedDelimiter=False Extract 119.99 ns 89.37 ns -25.5% 0.74x 312 B -> 312 B (0.0%) 1.00x
Sampled=True, UseEncodedDelimiter=False Inject 26.59 ns 28.38 ns +6.7% 1.07x 128 B -> 128 B (0.0%) 1.00x
Sampled=True, UseEncodedDelimiter=True Extract 120.75 ns 89.50 ns -25.9% 0.74x 312 B -> 312 B (0.0%) 1.00x
Sampled=True, UseEncodedDelimiter=True Inject 27.28 ns 27.20 ns -0.3% 1.00x 128 B -> 128 B (0.0%) 1.00x

Overall

  • Extract: faster in every shared suite on JaegerPropagator-perf, with the biggest wins in non-sampled cases (~54% lower duration).
  • Inject: one large win (-47.2%), two small regressions (+4.7% and +6.7%), and one effectively unchanged result.
  • Allocations: no change in any shared benchmark.

Detailed Results

Expand to view

main


BenchmarkDotNet v0.15.8, Windows 11 (10.0.26200.8246/25H2/2025Update/HudsonValley2)
13th Gen Intel Core i7-13700H 2.90GHz, 1 CPU, 20 logical and 14 physical cores
.NET SDK 10.0.203
  [Host]    : .NET 10.0.7 (10.0.7, 10.0.726.21808), X64 RyuJIT x86-64-v3
  .NET 10.0 : .NET 10.0.7 (10.0.7, 10.0.726.21808), X64 RyuJIT x86-64-v3

Job=.NET 10.0  Runtime=.NET 10.0  Toolchain=net10.0  

Method Sampled UseEncodedDelimiter Mean Error StdDev Ratio RatioSD Gen0 Allocated Alloc Ratio
Extract False False 212.57 ns 4.066 ns 3.804 ns 1.00 0.02 0.0248 312 B 1.00
Inject False False 54.12 ns 2.795 ns 7.975 ns 0.25 0.04 0.0102 128 B 0.41
Extract False True 200.61 ns 3.607 ns 3.542 ns 1.00 0.02 0.0248 312 B 1.00
Inject False True 27.55 ns 0.585 ns 1.220 ns 0.14 0.01 0.0102 128 B 0.41
Extract True False 119.99 ns 2.045 ns 1.708 ns 1.00 0.02 0.0248 312 B 1.00
Inject True False 26.59 ns 0.560 ns 1.144 ns 0.22 0.01 0.0102 128 B 0.41
Extract True True 120.75 ns 2.199 ns 2.057 ns 1.00 0.02 0.0248 312 B 1.00
Inject True True 27.28 ns 0.571 ns 0.984 ns 0.23 0.01 0.0102 128 B 0.41

This PR


BenchmarkDotNet v0.15.8, Windows 11 (10.0.26200.8246/25H2/2025Update/HudsonValley2)
13th Gen Intel Core i7-13700H 2.90GHz, 1 CPU, 20 logical and 14 physical cores
.NET SDK 10.0.203
  [Host]    : .NET 10.0.7 (10.0.7, 10.0.726.21808), X64 RyuJIT x86-64-v3
  .NET 10.0 : .NET 10.0.7 (10.0.7, 10.0.726.21808), X64 RyuJIT x86-64-v3

Job=.NET 10.0  Runtime=.NET 10.0  Toolchain=net10.0  

Method Sampled UseEncodedDelimiter Mean Error StdDev Ratio RatioSD Gen0 Allocated Alloc Ratio
Extract False False 98.98 ns 2.006 ns 2.746 ns 1.00 0.04 0.0248 312 B 1.00
Inject False False 28.58 ns 0.590 ns 1.245 ns 0.29 0.01 0.0102 128 B 0.41
Extract False True 92.99 ns 1.827 ns 2.438 ns 1.00 0.04 0.0248 312 B 1.00
Inject False True 28.85 ns 0.609 ns 1.143 ns 0.31 0.01 0.0102 128 B 0.41
Extract True False 89.37 ns 1.693 ns 1.738 ns 1.00 0.03 0.0248 312 B 1.00
Inject True False 28.38 ns 0.564 ns 1.238 ns 0.32 0.01 0.0102 128 B 0.41
Extract True True 89.50 ns 1.760 ns 1.807 ns 1.00 0.03 0.0248 312 B 1.00
Inject True True 27.20 ns 0.569 ns 1.353 ns 0.30 0.02 0.0102 128 B 0.41

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

Improve the performance of `JaegerPropagator` for .NET 8+ by using `SearchValues<T>`.
@github-actions github-actions Bot added the pkg:OpenTelemetry.Extensions.Propagators Issues related to OpenTelemetry.Extensions.Propagators NuGet package label Apr 25, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.08%. Comparing base (8bee1f4) to head (e7514a2).
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7171      +/-   ##
==========================================
- Coverage   89.10%   89.08%   -0.03%     
==========================================
  Files         271      271              
  Lines       13042    13063      +21     
==========================================
+ Hits        11621    11637      +16     
- Misses       1421     1426       +5     
Flag Coverage Δ
unittests-Project-Experimental 88.67% <100.00%> (-0.29%) ⬇️
unittests-Project-Stable 89.08% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...lemetry.Extensions.Propagators/JaegerPropagator.cs 96.03% <100.00%> (+0.79%) ⬆️

... and 2 files with indirect coverage changes

@martincostello martincostello marked this pull request as ready for review April 25, 2026 20:36
@martincostello martincostello requested a review from a team as a code owner April 25, 2026 20:36
Copilot AI review requested due to automatic review settings April 25, 2026 20:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to improve JaegerPropagator extraction performance on modern .NET by optimizing how the propagator splits the uber-trace-id header into components.

Changes:

  • Adds a .NET-specific fast-path for parsing header components using SearchValues<char> + IndexOfAny.
  • Introduces a cached delimiter hint set (: and %) for faster delimiter discovery.
  • Keeps the existing parsing implementation for non-.NET TFMs via conditional compilation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/OpenTelemetry.Extensions.Propagators/JaegerPropagator.cs
Do not silently scan past `%`.
@cijothomas
Copy link
Copy Markdown
Member

Given the component is to be deprecated, should we do perf improvements for it?

@martincostello
Copy link
Copy Markdown
Member Author

This was "free" as part of some performance investigation work I asked Copilot to do. I figured they were worth keeping rather than throwing away as we still ship this anyway.

@cijothomas
Copy link
Copy Markdown
Member

This was "free" as part of some performance investigation work I asked Copilot to do. I figured they were worth keeping rather than throwing away as we still ship this anyway.

I don't think this is "free". While copilot did a lot of heavy lifting, the review cycle isn't free for us — approver bandwidth is one of our biggest bottlenecks across OTel repos. I'd rather we save that energy for higher-impact work, like accelerating the deprecation/removal of this component.

Let's not make it harder for users to say goodbye to JaegerPropagator by making it faster! 🤣

@martincostello
Copy link
Copy Markdown
Member Author

If it had been a large change, I would have likely agreed, but for ~50 lines I considered it worth the improvement considering we still ship this package and it's mostly just adopting some newer APIs from .NET itself.

Copy link
Copy Markdown
Member

@rajkumar-rangaraj rajkumar-rangaraj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to acknowledge @cijothomas's point. Approver bandwidth across the OTel repos is tight right now, and I agree we should be prioritizing the higher-impact items.

@martincostello
Copy link
Copy Markdown
Member Author

Next time I get Copilot to do some speculative search for improvements, I'll make sure I tell it to exclude any areas marked as deprecated.

@martincostello martincostello added this pull request to the merge queue Apr 27, 2026
Merged via the queue into open-telemetry:main with commit ad7412c Apr 27, 2026
58 checks passed
@martincostello martincostello deleted the JaegerPropagator-perf branch April 27, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg:OpenTelemetry.Extensions.Propagators Issues related to OpenTelemetry.Extensions.Propagators NuGet package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants